﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="TRPOP.CMS.Web.ExtraBus.BasePage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>在线留言</title>
    <script src="../js/jquery.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        //留言信息提交
        function Submit() {
            $.ajax({
                type: "POST",
                url: "AddMessage.ashx",
                data: { MessageTitle: $("#txtMessageTitle").val(), MessageContent: $("#txtMessageContent").val(), MessageTypeID: $("#messageType").val(), MessageSend: $("#MessageSendID").val(), nvcMessageSend: $("#txtMessageSend").val(), ContactName: $("#txtContactName").val(), ContactGender: $("input[type=radio][name='Gender'][checked]").val(), ContactPhone: $("#Phone").val(), ContactMobile: $("#Mobile").val(), ContactAddress: $("#Address").val(), ContactEmail: $("#Email").val(), ContactPostCode: $("#PostCode").val() },
                async: true,
                error: function () {
                    alert("表单提交有误");
                },
                success: function (msg) {
                    if (msg == "MessageNull") {
                        alert("信息填写不完整!");
                    }
                    else if (msg == "OK") {
                        alert("留言添加完毕");
                        $("#form1")[0].reset();
                    }
                    else if (msg == "Error") {
                        alert("程序出错");
                    }
                }
            });
            return false;
        }
    </script>
    <script language="javascript" type="text/javascript">
        //还可传递的参数有：title  content  iSend nvcSend  type
        function GetMessageData() {
            $.getJSON("GetMessage.ashx?jsoncallback=?", { pagesize: 10, indexpage: 1, orderby: " [dtCreationTime] ASC ", MessageStatus: "2" }, function (data) {
                if (data.RecordCount == "0") {
                    var newTR = $('<tr class="tr_operator"></tr>');
                    $('<td class="align_l"></td>').text("暂无数据").appendTo(newTR);
                    $("#TopNews").append(newTR);
                }
                else {
                    $.each(data.DataList, function (i, n) {
                        var newTR = $('<tr class="tr_operator"></tr>'); //定义一个tr
                        $('<td class="align_l"></td>').text(n.MessageTitle).appendTo(newTR);
                        $('<td class="align_l"></td>').text(n.MessageContent).appendTo(newTR);
                        $('<td class="align_l"></td>').text(n.MessageCreationTime).appendTo(newTR);
                        $('<td class="align_l"></td>').text(n.ReplyTime).appendTo(newTR);
                        $('<td class="align_l"></td>').text(n.ReplyContent).appendTo(newTR);
                        $("#TopNews").append(newTR);
                    });
                }
            }
    );
        }
        $(document).ready(function () {
            GetMessageData();
        });
    </script>
</head>
<body>
    <table id="TopNews">
        <tr>
            <td colspan="5" align="center">
                留言信息列表
            </td>
        </tr>
        <tr>
            <td style=" width:90px;">
                留言主题
            </td>
            <td style=" width:90px;">
                留言内容
            </td>
            <td style=" width:90px;">
                留言时间
            </td>
            <td style=" width:90px;">
                回复时间
            </td>
            <td style=" width:90px;">
                回复内容
            </td>
        </tr>
    </table>
    <form id="form1" onsubmit="return Submit();">
    <div>
        <table>
            <tr>
                <td>
                    留言标题：
                </td>
                <td>
                    <input type="text" id="txtMessageTitle" name="txtMessageTitle" maxlength="180" />
                </td>
            </tr>
            <tr>
                <td>
                    留言内容：
                </td>
                <td>
                    <textarea rows="5" cols="20" id="txtMessageContent" name="txtMessageContent"></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    留言类型：
                </td>
                <td>
                    <select id="messageType" name="messageType">
                        <option value="1" selected="selected">普通</option>
                        <option value="2">建议</option>
                        <option value="3">咨询</option>
                        <option value="4">合作</option>
                        <option value="5">其他</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    收件人ID：
                </td>
                <td>
                    <input type="text" id="MessageSendID" name="MessageSendID" maxlength="18" />
                </td>
            </tr>
            <tr>
                <td>
                    收件人姓名：
                </td>
                <td>
                    <input type="text" id="txtMessageSend" name="txtMessageSend" maxlength="18" />
                </td>
            </tr>
            <tr>
                <th colspan="2">
                    联系人基本信息
                </th>
            </tr>
            <tr>
                <td>
                    联系人姓名：
                </td>
                <td>
                    <input type="text" id="txtContactName" name="txtContactName" maxlength="18" />
                </td>
            </tr>
            <tr>
                <td>
                    性别：
                </td>
                <td>
                    <input type="radio" value="1" name="Gender" checked />男
                    <input type="radio" value="2" name="Gender" />女
                </td>
            </tr>
            <tr>
                <td>
                    邮箱：
                </td>
                <td>
                    <input type="text" id="Email" name="Email" maxlength="180" />
                </td>
            </tr>
            <tr>
                <td>
                    固话：
                </td>
                <td>
                    <input type="text" id="Phone" name="Phone" maxlength="18" />
                </td>
            </tr>
            <tr>
                <td>
                    手机：
                </td>
                <td>
                    <input type="text" id="Mobile" name="Mobile" maxlength="19" />
                </td>
            </tr>
            <tr>
                <td>
                    邮编：
                </td>
                <td>
                    <input type="text" id="PostCode" name="PostCode" maxlength="18" />
                </td>
            </tr>
            <tr>
                <td>
                    地址：
                </td>
                <td>
                    <input type="text" id="Address" name="Address" maxlength="180" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <input type="submit" name="" value="提交" />&nbsp;&nbsp;&nbsp;<input id="Reset1" type="reset"
                        value="重置" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
